package com.hziee.cosmanage.manageandhr.service.impl;

import com.alibaba.fastjson.TypeReference;
import com.hziee.common.utils.R;
import com.hziee.cosmanage.manageandhr.feign.MemberfeignService;
import com.hziee.cosmanage.manageandhr.vo.UserInviteVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hziee.common.utils.PageUtils;
import com.hziee.common.utils.Query;

import com.hziee.cosmanage.manageandhr.dao.InviteDao;
import com.hziee.cosmanage.manageandhr.entity.InviteEntity;
import com.hziee.cosmanage.manageandhr.service.InviteService;


@Service("inviteService")
public class InviteServiceImpl extends ServiceImpl<InviteDao, InviteEntity> implements InviteService {

    @Autowired
    MemberfeignService memberfeignService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InviteEntity> page = this.page(
                new Query<InviteEntity>().getPage(params),
                new QueryWrapper<InviteEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void publishInvite(InviteEntity inviteEntity) {
        this.save(inviteEntity);
    }

    @Override
    public List<UserInviteVo> approveIntroduce(Integer cId) {
        R introduce = memberfeignService.getIntroduce(cId);
        List<UserInviteVo> data = introduce.getData(new TypeReference<List<UserInviteVo>>() {
        });
        return data;
    }

}